Strip XF86 prefix from untranslated keysyms
authorMatthias Clasen <mclasen@redhat.com>
Fri, 4 Feb 2011 20:34:36 +0000 (15:34 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 4 Feb 2011 20:34:36 +0000 (15:34 -0500)
When we don't have translations, at least remove the
ugly XF86 prefix.

gtk/gtkaccellabel.c

index e354d279c14efa254d44cc5cd8db72eef0eeb052..0b0e1bc780de06e3f54b157102cfe3b64648e60c 100644 (file)
@@ -600,7 +600,7 @@ gtk_accel_label_get_string (GtkAccelLabel *accel_label)
  * E.g., Page_Up should be "Page Up"
  */
 static void
-substitute_underscores (char *str)
+substitute_underscores (gchar *str)
 {
   char *p;
 
@@ -609,6 +609,20 @@ substitute_underscores (char *str)
       *p = ' ';
 }
 
+/* Some keynames have prefixes that are not suitable
+ * for display, e.g XF86AudioMute
+ */
+static gchar *
+strip_prefix (gchar *str)
+{
+  if (g_str_has_prefix (str, "XF86"))
+    return str + 4;
+  else if (g_str_has_prefix (str, "ISO_"))
+    return str + 4;
+
+  return str;
+}
+
 /* On Mac, if the key has symbolic representation (e.g. arrow keys),
  * append it to gstring and return TRUE; otherwise return FALSE.
  * See http://docs.info.apple.com/article.html?path=Mac/10.5/en/cdb_symbs.html 
@@ -833,8 +847,9 @@ _gtk_accel_label_class_get_accelerator_label (GtkAccelLabelClass *klass,
               str = g_dpgettext2 (GETTEXT_PACKAGE, "keyboard label", tmp);
              if (str == tmp)
                {
+                 substitute_underscores (tmp);
+                  tmp = strip_prefix (tmp);
                  g_string_append (gstring, tmp);
-                 substitute_underscores (gstring->str);
                }
              else
                g_string_append (gstring, str);